var slideshowUrl = "http://doodle4googleau.googlecode.com/svn/trunk/mapplet/d4gplayer.html";
var map;

function renderGadget(idschool) {
	var selectedState = document.getElementById('stateMenu').value;
	var stateMap = schoolMap[selectedState];
	//console.log("idschool: " + idschool);
	//console.log("name: " + stateMap[idschool]["name"]);	
	//console.log("latitude: " + stateMap[idschool]["lat"]);	
	//console.log("longitude: " + stateMap[idschool]["lng"]);	
	//console.log("doodles: " + stateMap[idschool]["idd"]);	
	var html = [];
	var snlist = "";
	var yllist = "";
	//for (doodleId in stateMap[idschool]["idd"]) {
	for (var i = 0; i < stateMap[idschool]["idd"].length; i++) {
		var doodleId = stateMap[idschool]["idd"][i];
		snlist += doodleMap[doodleId]["sn"] + ",";
		yllist += doodleMap[doodleId]["yl"] + ",";
	}
	var didlist = stateMap[idschool]["idd"].join(',');
	d4gp = new D4GPlayer(idschool, stateMap[idschool]["name"], didlist, snlist, yllist);
	d4gp.loadImage(0);
	_IG_AdjustIFrameHeight();
}

function populateList() {
	var selectedState = document.getElementById('stateMenu').value;
	var html = [];
	html.push('<select id="school" size=1 onchange="renderGadget(this.value);" class="mainForm">');	
	if (selectedState != '') {
		var stateMap = schoolMap[selectedState];
		for (var schoolId in stateMap) {
			var schoolName = stateMap[schoolId]["name"];
			html.push('<option value=\'' + schoolId + '\' id=\'list-' + schoolId + '\'>' + schoolName + '</option>');
		}
	}
	html.push('</select>');
	var listElement = document.getElementById('list');
	listElement.innerHTML = html.join('');
	if (listElement.value == '') {
		listElement.disabled = true;
	}
	renderGadget(document.getElementById('school').value);
}